﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataProdArchive" @search="()=>{getTableDataProdArchive();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Sn_FormItem" prop="Sn" :label="$t('message.autotrans._Model_ProdArchive_Sn')">
            <el-input v-model="searchDataProdArchive.Sn" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductId_FormItem" prop="ProductId" :label="$t('message.autotrans._Model_ProdArchive_ProductId')">
            <el-input v-model="searchDataProdArchive.ProductId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductCode_FormItem" prop="ProductCode" :label="$t('message.autotrans._Model_ProdArchive_ProductCode')">
            <el-input v-model="searchDataProdArchive.ProductCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Wo_FormItem" prop="Wo" :label="$t('message.autotrans._Model_ProdArchive_Wo')">
            <el-input v-model="searchDataProdArchive.Wo" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="LineId_FormItem" prop="LineId" :label="$t('message.autotrans._Model_ProdArchive_LineId')">
            <el-input v-model="searchDataProdArchive.LineId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="LineCode_FormItem" prop="LineCode" :label="$t('message.autotrans._Model_ProdArchive_LineCode')">
            <el-input v-model="searchDataProdArchive.LineCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OpId_FormItem" prop="OpId" :label="$t('message.autotrans._Model_ProdArchive_OpId')">
            <el-input v-model="searchDataProdArchive.OpId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OpCode_FormItem" prop="OpCode" :label="$t('message.autotrans._Model_ProdArchive_OpCode')">
            <el-input v-model="searchDataProdArchive.OpCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="RoutingId_FormItem" prop="RoutingId" :label="$t('message.autotrans._Model_ProdArchive_RoutingId')">
            <el-input v-model="searchDataProdArchive.RoutingId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="RoutingCode_FormItem" prop="RoutingCode" :label="$t('message.autotrans._Model_ProdArchive_RoutingCode')">
            <el-input v-model="searchDataProdArchive.RoutingCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="InboundTime_FormItem" prop="InboundTime" :label="$t('message.autotrans._Model_ProdArchive_InboundTime')">
            <el-date-picker v-model="searchDataProdArchive.InboundTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Status_FormItem" prop="Status" :label="$t('message.autotrans._Model_ProdArchive_Status')">
            <el-select v-model="searchDataProdArchive.Status" clearable>
               <el-option key="OK" value="OK" :label="$t('message.autotrans._Enum_SnStatusEnum_OK')"></el-option>
               <el-option key="NG" value="NG" :label="$t('message.autotrans._Enum_SnStatusEnum_NG')"></el-option>
               <el-option key="MandatoryOK" value="MandatoryOK" :label="$t('message.autotrans._Enum_SnStatusEnum_MandatoryOK')"></el-option>
               <el-option key="MandatoryNG" value="MandatoryNG" :label="$t('message.autotrans._Enum_SnStatusEnum_MandatoryNG')"></el-option>
               <el-option key="Scrap" value="Scrap" :label="$t('message.autotrans._Enum_SnStatusEnum_Scrap')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OutboundTime_FormItem" prop="OutboundTime" :label="$t('message.autotrans._Model_ProdArchive_OutboundTime')">
            <el-date-picker v-model="searchDataProdArchive.OutboundTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Shift_FormItem" prop="Shift" :label="$t('message.autotrans._Model_ProdArchive_Shift')">
            <el-input v-model="searchDataProdArchive.Shift" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CycleTime_FormItem" prop="CycleTime" :label="$t('message.autotrans._Model_ProdArchive_CycleTime')">
            <el-input v-model="searchDataProdArchive.CycleTime" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_ProdArchive_CreateTime')">
            <el-date-picker v-model="searchDataProdArchive.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_ProdArchive_UpdateTime')">
            <el-date-picker v-model="searchDataProdArchive.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_ProdArchive_CreateBy')">
            <el-input v-model="searchDataProdArchive.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_ProdArchive_UpdateBy')">
            <el-input v-model="searchDataProdArchive.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/ProductionManagement/ProdArchive/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/ProductionManagement/ProdArchive/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/ProductionManagement/ProdArchive/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/ProductionManagement/ProdArchive/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/ProductionManagement/ProdArchive/ProdArchiveExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefProdArchive" v-bind="tableDataProdArchive">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/ProductionManagement/ProdArchive/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/ProductionManagement/ProdArchive/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/ProductionManagement/ProdArchive/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageProductionManagementProdArchiveIndex;true;Digitalmes.ProductionManagement.Controllers;ProdArchive">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { prodarchiveApi } from '/@/api/productionmanagement/prodarchive';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateProdArchive = reactive({
    
});

const searchDataProdArchive = ref({
        Sn: '',
        ProductId: null,
        ProductCode: '',
        Wo: '',
        LineId: null,
        LineCode: '',
        OpId: null,
        OpCode: '',
        RoutingId: null,
        RoutingCode: '',
        InboundTime: undefined,
        Status: undefined,
        OutboundTime: undefined,
        Shift: '',
        CycleTime: null,
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefProdArchive = ref();
const tableDataProdArchive = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page追溯码'),key: 'ProdArchive_Sn',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品Id'),key: 'ProdArchive_ProductId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品编码'),key: 'ProdArchive_ProductCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工单号'),key: 'ProdArchive_Wo',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产线Id'),key: 'ProdArchive_LineId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产线编号'),key: 'ProdArchive_LineCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工位'),key: 'ProdArchive_OpId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工位编号'),key: 'ProdArchive_OpCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工艺路线'),key: 'ProdArchive_RoutingId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工艺路线编号'),key: 'ProdArchive_RoutingCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工位进站时间'),key: 'ProdArchive_InboundTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page状态'),key: 'ProdArchive_Status',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工位出站时间'),key: 'ProdArchive_OutboundTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page班次'),key: 'ProdArchive_Shift',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page用时'),key: 'ProdArchive_CycleTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateTime'),key: 'ProdArchive_CreateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateTime'),key: 'ProdArchive_UpdateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateBy'),key: 'ProdArchive_CreateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateBy'),key: 'ProdArchive_UpdateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminIsValid'),key: 'ProdArchive_IsValid',type: 'switch',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataProdArchive = () => {
    tableRefProdArchive.value.doSearch(prodarchiveApi().search, searchDataProdArchive.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataProdArchive)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataProdArchive)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataProdArchive)
};

// 删除
const onDelete = (row: any) => {
    prodarchiveApi().delete([row.ID]).then(() => { getTableDataProdArchive()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefProdArchive.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      prodarchiveApi().delete(selectedids).then(() => { getTableDataProdArchive()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefProdArchive.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataProdArchive)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataProdArchive)
};

const onExport = () => {
	const selected = tableRefProdArchive.value.getSelectedRows();
	if (selected.length > 0) {
		prodarchiveApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		prodarchiveApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
        getTableDataProdArchive();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

